package com.meng.mmlive.ui.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.widget.FrameLayout;

import com.chanven.lib.cptr.PtrFrameLayout;
import com.chanven.lib.cptr.PtrUIHandler;
import com.chanven.lib.cptr.indicator.PtrIndicator;
import com.meng.mmlive.R;

/**
 * Created by Administrator on 2017/5/14.
 */

public class PtrClassicHeader extends FrameLayout implements PtrUIHandler {
    public PtrClassicHeader(Context context) {
        super(context);
        initViews();
    }

    public PtrClassicHeader(Context context, AttributeSet attrs) {
        super(context, attrs);
        initViews();
    }
    private RefreshView refreshView;
    private void initViews() {
        LayoutInflater.from(getContext()).inflate(R.layout.v_refreshview, this);
        refreshView = (RefreshView) findViewById(R.id.refreshHeader);
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(0,0);
        layoutParams.gravity = Gravity.CENTER;
        refreshView.setLayoutParams(layoutParams);
    }

    @Override
    public void onUIReset(PtrFrameLayout frame) {
        refreshView.stopRefresh();
    }

    @Override
    public void onUIRefreshPrepare(PtrFrameLayout frame) {
        refreshView.startRefresh();
    }

    @Override
    public void onUIRefreshBegin(PtrFrameLayout frame) {
        refreshView.startRefresh();
    }

    @Override
    public void onUIRefreshComplete(PtrFrameLayout frame) {
        refreshView.stopRefresh();
    }

    @Override
    public void onUIPositionChange(PtrFrameLayout frame, boolean isUnderTouch, byte status, PtrIndicator ptrIndicator) {
    }
}
